﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Employees_EmpWorkExprience : System.Web.UI.Page
{
    private Srvtools.WebDataSet WMaster;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
             InitializeComponent();
            if (Request["Wid"] != null)
            {
                WMaster.SetWhere("Eid=" + Request["Wid"].ToString());
            }

            if (Request["eid"] != null)
            {
                hidEid.Value = Request["eid"].ToString();
                hidEname.Value = Server.UrlDecode(Request["ename"].ToString());

                spHistory.Visible = true;
            }
            else
            {
                spHistory.Visible = false;
            }

            Master.DataSource = WMaster;



            MasterPage_MasterPage master = (MasterPage_MasterPage)this.Page.Master;

            master.HelpHref = "";
            master.PageName = "工作经历";
            master.PicUrl = "~/image/PageIcon/hetong.jpg";
            master.IntiBar();

        }
    }

    private void InitializeComponent()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Employees_EmpWorkExprience));
        this.WMaster = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).BeginInit();
        // 
        // WMaster
        // 
        this.WMaster.Active = true;
        this.WMaster.AlwaysClose = true;
        this.WMaster.DataCompressed = false;
        this.WMaster.DeleteIncomplete = true;
        this.WMaster.Guid = null;
        this.WMaster.LastKeyValues = null;
        this.WMaster.Locale = new System.Globalization.CultureInfo("zh-CN");
        this.WMaster.PacketRecords = 100;
        this.WMaster.Position = -1;
        this.WMaster.RemoteName = "SEmployees.EmpWorkExprience";
        this.WMaster.ServerModify = true;
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).EndInit();

    }

    protected void EmpInsurance_DataBound(object sender, EventArgs e)
    {
        if (Request["action"] != null)
        {
            if (Request["action"].ToString() == "view" || Request["action"].ToString() == "self")
            {
                wn.Visible = false;
            }

        }

        if (hidEid.Value != "")
        {
            Control_SelUser su = EmpInsurance.FindControl("SelUser") as Control_SelUser;
            su.ReadOnly(hidEid.Value, hidEname.Value);

            if (Request["action"] != null)
            {
                if (Request["action"].ToString() == "onlyadd")
                {
                    spHistory.Visible = false;
                }
            }
        }
        else
        {
            Control_SelUser su = EmpInsurance.FindControl("SelUser") as Control_SelUser;
            su.SelUserInti("", "");
        }
    }

    protected void wnHr_Command(object sender, CommandEventArgs e)
    {


        if (e.CommandName == "cmdFirst" || e.CommandName == "cmdPrevious"
            || e.CommandName == "cmdNext" || e.CommandName == "cmdLast")
        {
            Master.ExecuteSelect(EmpInsurance);
            DataBind();
        }
        else if (e.CommandName == "cmdAdd")
        {
            DataBind();
        }
        else if (e.CommandName == "cmdDelete")
        {
            Master.ExecuteSelect(EmpInsurance);
            DataBind();
        }
        else if (e.CommandName == "cmdApply" && EmpInsurance.AllValidateSucess)
        {
            Master.ExecuteSelect(EmpInsurance);
            DataBind();
            if (Request["action"] != null)
            {
                if (Request["action"].ToString() == "onlyadd")
                {
                    ClientScript.RegisterStartupScript(GetType(), "Msg", "alert('添加成功');parent.location.reload()", true);
                }
            }
        }
    }

    protected void Master_Adding(object sender, Srvtools.WebDataSourceAddingEventArgs e)
    {
        try
        {
            Control_SelUser su = EmpInsurance.FindControl("SelUser") as Control_SelUser;
            if (su.EmployeeId == "")
            {
                return;
            }
            else
            {
                e.AddingValues["EmployeeID"] = su.EmployeeId;

                hidEid.Value = su.EmployeeId;
                hidEname.Value = su.EmpName;
            }
        }
        catch
        {
            return;
        }


    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        string action = "";
        if (Request["action"] != null)
        {
            action = "&action=" + Request["action"].ToString();
        }

        string mode = "";
        if (Request["mode"] != null)
        {
            mode = "&mode=" + Request["mode"].ToString();
        }

        Response.Redirect("EmpWorkExprienceList.aspx?eid=" + hidEid.Value + action + mode);
    }
}
